﻿package at.geoathome.ui.buttons
{
	import  at.geoathome.ui.buttons.Checkbox;
	import  at.geoathome.ui.buttons.RadioButtonSets;
	
	/**
	* ...
	* @author Georg Kamptner
	*/
	public class RadioButton extends Checkbox
	{
		private var _radio_button_sets:RadioButtonSets;
		private var _radio_button_set_id:String;
		
		public function RadioButton(bg_classname:String = Button.INVISIBLE_BACKGROUND, auto_check:Boolean = true, radio_button_set_id:String = "default")
		{
			super(bg_classname, auto_check);
			
			_radio_button_sets = RadioButtonSets.getInstance();
			_radio_button_sets.addRadioButton(this, radio_button_set_id);
			_radio_button_set_id = radio_button_set_id;
		}
		
		public override function set checked(checked:Boolean):void
		{
			if (checked)
			{
				activate();
				// Radio Button Set - Management
				_radio_button_sets.handleButtonCheck(this, _radio_button_set_id);
			} else {
				deactivate();
			}
		}		
		
	}
	
}